﻿function erclose()
{
    if($get("valContent").style.display=="")
    {
        $get("valContent").style.display='none';
    }
}
//添加小黑板信息
function AddComm()
{
var con=$get("txtCommInput").value;
    if(con==""||con.length>1999)
    {
        $get("valContent").style.display=''; 
        return;
    }
    $get("btnCommInput").disabled=true;
    showProgressBar(true);
    if(Memberno=="")
    {
        top.location = "/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;
        return;
    }    
    
    WebServices.My.AddGetComment(Memberno,1,10,con,onsuccAc);    
}
//初始化添加小黑板的数据
function onsuccAc(result)
{
      showProgressBar(false);
    $get("btnCommInput").disabled=false;
      if(result!=null&&result[0]==1){_count=result[2].RecordCount;
    RendComList(result[1],"CommentList");

}
   else
    {
       
       $get("MessagesBox").style.display='';
        $get("MessageImg").src = MessageImageF;
        $get("MessageText").innerHTML = MessageTextF;
    }
    $get("btnCommInput").disabled=false;
             showProgressBar(false);
}


function RendComList(list,divID)
{
    var domDiv1 = $get(divID);   
    if(domDiv1!=null)
    {
        if(Sys.UI.DomElement.containsCssClass(domDiv1, "DisplayNone"))
        {
            Sys.UI.DomElement.removeCssClass(domDiv1, "DisplayNone");
        }
        if($get("CommentTemplate")==null) return;
        var item= $get("CommentTemplate").innerHTML;
        var listBuilder = new Sys.StringBuilder();
        for (var index = 0; index < list.length; ++index) 
        {
            var obj = list[index];
            var tmp = item.replace(/\$Avatar\$/gi,"<img src=\""+(obj.avatar==""?"/Images/No_pic.gif":obj.avatar)+"\"/>");
            tmp = tmp.replace(/\$NickName\$/gi,obj.nickname);
            tmp = tmp.replace(/\$userFrom\$/gi,obj.userFrom);
            tmp = tmp.replace(/\$content\$/gi,EncodeMessage(obj.content));            
            var arr1 = gDateFormat.split(":");
            var arr2 =obj.DiffDate.split(":");
            if(arr2[0]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[0]).replace("{1}",arr1[0]));
            }
            else if(arr2[1]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[1]).replace("{1}",arr1[1]));
            }
            else if(arr2[2]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[2]).replace("{1}",arr1[2]));
            }
            else if(arr2[3]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[3]).replace("{1}",arr1[3]));
            }
            else if(arr2[4]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[4]).replace("{1}",arr1[4]));
            }
            else if(arr2[5]>0)
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,gStrDate2.replace("{0}",arr2[5]).replace("{1}",arr1[5]));
            }
            else
            {
                tmp = tmp.replace(/\$CreateDate\$/gi,"");
            }
            listBuilder.append(tmp);
        }
        domDiv1.innerHTML = listBuilder.toString();
        $("txtCommInput").value="";
        $('comcount').innerHTML="("+_count+")";
   }
}
function up_launchWM(userID,destinationUserID,destinationName)
    {
        window.open( "/webchat/wm_ads.aspx?strDestinationUserID=" + destinationUserID, "WMWindow_" + up_replaceAlpha(userID) + "_" + up_replaceAlpha(destinationUserID), "width=500,height=600,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
    }
function up_launchUL()
{		
    window.open( "[[path to your ul or ul_ads file]]" , "ULWindow" , "width=200,height=750,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
}
function up_replaceAlpha( strIn )
{
    var strOut = "";
    for( var i = 0 ; i < strIn.length ; i++ )
    {
        var cChar = strIn.charAt(i);
        if( ( cChar >= 'A' && cChar <= 'Z' )
            || ( cChar >= 'a' && cChar <= 'z' )
            || ( cChar >= '0' && cChar <= '9' ) )
        {
            strOut += cChar;
        }
        else
        {
            strOut += "_";
        }
    }
    return strOut;
}